Karan Bhandari's profile

SIL – Simple Interpreted Language

Introduction
SIL(Simple Interpreted Language) is a programming language that is translatedstatement by statement and executed as translation occurs.
SIL Studio is an IDE that we developed that translates SIL statements
SIL STUDIO
A Sample Program that executes on SIL Studio
  FUNCTIONpoll(iota,jun)
BEGIN
INTEGER france
PRINTLN"function"
LET france=iota+jun
END
FUNCTIONking(lion,samba)
BEGIN
PRINTLN"lincon"
END
FUNCTIONCIRCUM(RADIUS)
BEGIN
INTEGER CIR
LETCIR=2*RADIUS*3.14
END
INTEGER A
INTEGER B
BOOL D
LET A=(67+89)-90
READ B
LET D=56>B
PRINTLN"a",A
PRINTLN"D",D
poll(8,9)
king(3,4)
CIRCUM(4)
PRINTLN"France=",france
WHILE B<10 DO
BEGIN
LET B=B+1
PRINTLN"fj"
WHILEEND
RECTANGLE 45,67
IF 45>32 THEN
IF 45>56 THEN
PRINTLN"BARA"
PRINTLN"LION"
PRINTLN""
PRINT"CIRCUMFERENCE IS ",CIR
FOR 2 TO 5 DO
BEGIN
PRINTLN"GATHER LIGHT"
PRINTLN"AND HARVEST"
FOREND
CONNECT com2,9600
SEND 567
RECEIVE

(Last three lines achieves connectivity to NEXYS2 Digilent FPGA board)

Features of SIL
Variables
1. You can store values in variables.
2. Each variable is identified by a variable name.
3. Each variable has a variable type.
4. Variable names start with a letter or underscore (_), followed by any number of letters, digits, or underscores.
5. Uppercase is different from lowercase, so the names sam, Sam, and SAM specify three different variables.
6. The variables are defined at the beginning of the block.



Data Types
DATA TYPE RNAGE MEANING IN REAL WORLD
INTEGER
–2,147,483,648 to 2,147,483,647 Signed 32-bit number
FLOAT 1.55*10-45 to 3.45*1038 32-bit floating point
BOOL True or False Truth or Falsity of a statement
STRING Limited by System Memory Set of UNICODE characters

The member variables of class types are automatically set to an appropriate default value. This value will differ based on the exact data type; however, the rules are simple:
• BOOL types are set to false.
• INTEGER data is set to 0 (or 0.0 in the case of floating-point data types).
• STRING types are set to null

Statements
SIL INTEGER Statement

The INTEGER statement allows a SIL program to declare integer variables.

Syntax Example
INTEGER identifier INTEGER var


SIL BOOL Statement

It allows user to input the truth or falsity of a statement.


Syntax Example
BOOL identifier BOOL var


SIL LET Statement

The LET statement allows a SIL program to assign a value to a previously declared variable.
Semantically, expression is evaluated and the resulting single integer value is assigned to variable. A variable may be changed only through LET and may be changed as often as necessary.


Syntax Example
LET identifier=expression LET A=(89+9)*9/8


SIL PRINT Statement

The PRINT statement allows a SIL program to display either integer expressions or string literals to the output.

An empty PRINT does nothing. Semantically, if print item is an expression, expression is evaluated and the resulting single integer value displayed. If the print item is a LITERAL, the literal is displayed verbatim.


Syntax Example
PRINT [[expression | LITERAL] [,expression | LITERAL]] PRINT “Value of A is”,A


SIL PRINTLN Statement

The PRINTLN statement performs exactly the same as PRINT, except that after all items have been printed, a carriage return and line feed (newline) is displayed. The syntax for PRINTLN is


If an empty PRINTLN is issued and the cursor is on an empty line, the result is an empty line of text is displayed. It an empty PRINTLN is issued and the cursor is not on an empty line, the result is the cursor is moved to the start of the next line in the display.

Syntax Example
PRINTLN [[expression | LITERAL] [,expression | LITERAL]] PRINTLN “Value of A is”,A



SIL READ Statement

The READ statement allows a SIL program to accept integer input from the keyboard. READ reads only one variable per statement. The syntax for READ is
Syntax Example
READ variable READ A



The value entered at the input box. Once the user inputs the value, he/she pushes the OK button. The value is stored in the value field of the identifier in the symbol table.

SIL IF..THEN Statement


The IF…THEN statement allows a SIL program to conditionally execute one statement if the simple relational expression evaluates to true. The syntax for IF…THEN is

IF relational_expression THEN
statement
relational_expression consists of
expression {= | > | <} expression
If relational_expression evaluates to true, then statement is executed. If relational_expression evaluates to false, statement is skipped.



SIL Expressions

An expression in SIL consists of constants, identifiers and arithmetic operators combined in such a way as to reduce to a single integer value. . Expressions may contain parenthesis. Individual expressions may have at most one leading plus or minus sign. Expressions that have a leading sign must be either the only expression or have parenthesis enclosing both the sign and the expression. In SIL, expressions are recursive.
SIL While Statement

The WHILE statement shall permit the repetition of a program statement or statements (using BEGIN..WHILEEND blocks). The syntax is

WHILE relational_expression DO
Statement
SIL FOR statement
The WHILE statement shall permit the repetition of a program statement or statements (using BEGIN..FOREND blocks). The syntax is

WHILE relational_expression DO
Statement
SIL FUNCTION decleration

The FUNCTION statement defines a callable function with unlimited parameters. The syntax is
FUNCTION Identifier ( integer parameter list)
BEGIN
Statement(s)
END

All the variables are global so there is no return type.
Drawing
Syntax
RECTANGLE x,y
LINE x,y


GUI

• The GUI features a menu bar having buttons such as File, Edit, View, Tools and Help.
• Tool bar includes functionalities which are frequently used such as new file, open file, save, print, cut, copy, paste and help.
• The GUI contains a rich textbox to input the code.
• The code can be executed by pressing the compilation button represented by ‘Boom’ on the right side of the code text box.
• Below the ‘Boom’ drawing functionality output is displayed.
• Various tabs are provided below the code textbox such as Output which displays the output generated by the code, DebugInfo provides us line by line correctness of the program. Error tab shows the errors present in the program, the Error Expound tab shows the error in detail by providing stack trace and the target site of the error. Database tab shows the grid view of the current source code.
• An error indicator is present at the right bottom corner represented by ‘Error?’ . Presence of an error is indicated by red color.

TO USE NEXYS through SIL Studio

-Download the bit file to the board using illustrations below.
-Following command connects
CONNECT <port>,<baud>
example
CONNECT com2,9600
- In order to send
SEND <text to be sent>
Example
SEND 5
-Following Command receives
RECEIVE
NEXYS2 Interfacing
ARCHITECTURE OF SIL
Technologies Used
.NET, Verilog

Project Team
Manmath Kirsan & Karan Bhandari
under Dr. Michael Hoffman and Prof. John Tramel of CSULB
SIL – Simple Interpreted Language
Published:

SIL – Simple Interpreted Language

SIL (Simple Interpreted Language) is a programming language that is translated statement by statement and executed as the translation occurs.

Published:

Creative Fields